package com.spring.demo.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.spring.demo.util.Constant;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.spring.demo.model.user.User;
import com.spring.demo.model.vo.ResponseVo;
import com.spring.demo.service.user.UserService;

/**
 * 访问层公共类
 * @author ld2016
 *
 */
@Controller
//@RequestMapping("/")
public class BaseController {
	
	/**
	 * 状态返回类
	 */
	protected ResponseVo<Boolean> responseVo;

	/**
	 * 用户类service
	 */
	@Resource(name = UserService.SERVICE_NAME)
	protected UserService userService;
	
	@RequestMapping(value = "/login",method = RequestMethod.GET)
	public String login() {
		System.out.println("qwe");
		return "login";
	}
	
	/*@RequestMapping(value = "/loginout",method = RequestMethod.GET)
	public String loginout(){
		System.out.println("退出登录--------");
		return "login";
	}*/
	
	/*@RequestMapping(value = "/login",method = RequestMethod.POST)
	public String login2() {
		System.out.println(123);
		return "index";
	}*/
	
	//security跳转页面
		@RequestMapping(value="loginSuccess",method=RequestMethod.GET)
		public String loginSuccess(HttpServletRequest request) {
			User user = (User) request.getSession().getAttribute(Constant.LOGIN_USER);
			System.out.println(user.getUserName());
			
			return "index";
		}
		
		@RequestMapping(value="adminLoginSuccess",method=RequestMethod.GET)
		public String adminLoginSuccess() {
			return "admin/admin";
		}
	
		@RequestMapping(value="Access_Denied",method=RequestMethod.POST)
		public String Access_Denied(){
			return "Access_Denied";
		}
	
	/**
	 * 跳转mainframe页面
	 * @return
	 */
	@RequestMapping(value = "/mainframe",method = RequestMethod.GET)
	public String toMainFrame(){
		return "mainframe";
	}
}
